package br.com.servlet.controller;

import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import br.com.model.Usuario;

@Controller
public class LoginController 
{
	@RequestMapping("efetuaLogin")
	public String efetuaLogin( Usuario usuario, HttpSession session )
	{
		Usuario usrADM = new Usuario( );
		usrADM.setUsuario( "admsteam" );
		usrADM.setSenha  ( "137955"   );
		
		if( usuario.equals( usrADM ) )
		{
			session.setAttribute( "usuarioLogado", usuario );
			
			return "index";
		}
		
		return "redirect:loginForm.jsp";
	}
	
	@RequestMapping("logout")
	public String logout( HttpSession session )
	{
	  session.invalidate( );
	  return "redirect:loginForm.jsp";
	}
}